package com.molin.StreamTest;

import java.util.ArrayList;
import java.util.List;

public class Demo1 {
    public static void main(String[] args) {
        ArrayList<String> nameList=new ArrayList<>(List.of("张三丰","张无忌","谢敏","张良","王二麻子","张隆基"));
//        ceshi(nameList);


        System.out.println("================Stream================");
        nameList.stream().filter( s -> s.startsWith("张") )
                .filter(s -> s.length()==3)
                .forEach(s-> System.out.println(s));
    }

    public static void ceshi(ArrayList<String> nameList) {
        //找到所有姓张的人
        ArrayList<String> zhangNmaeList=new ArrayList<>();
        for (String s : nameList) {
            if (s.startsWith("张"))
            zhangNmaeList.add(s);
        }
        //找到三个字的
        ArrayList<String> zhangSanzi=new ArrayList<>();
        for (String s : zhangNmaeList) {
            System.out.println(s);
            if(s.length()>=3){
                zhangSanzi.add(s);
            }
        }
        System.out.println("=========");
        for (String s : zhangSanzi) {
            System.out.println(s);
        }
    }
}
